/***************************************************************************
 创建者: 华磊
 开始时间: 2020.8.14
 copyright: (C) 华友高科
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) hualei 2020.5.8 类的具体实现代码编写

 ***************************************************************************
 *  @file x.h
 *  功能:
 *
 *                                                                         *
 ***************************************************************************/

#ifndef IMUDEVICE_H
#define IMUDEVICE_H
#include <QString>
#include "globalDefine.h"
#include <QObject>

typedef struct _modbus modbus_t;
class QSerialPort;
struct SerialPortConfig;

class ImuDevice : public QObject
{
        Q_OBJECT
public:
    ImuDevice(QString configFileNameIn);

public:
    int getImuDeviceData(ImuDataInfo &dataOut);
    int receiveImuDeviceData(ImuDataInfo &dataOut);
    bool isUseThisModule();
    bool isInitialOk();

private slots:
       void receiveData();

private:

      int initialConfigFile(QString configFileName);
      int initalSerialPort();
       int initialModbusMaster(SerialPortConfig *serialPortConfigIn,int aliasIdIn);

      int receiveRawDataOnce_WIT(QByteArray &receiveBatteryData);
      void decodeIMUData(unsigned char dataIn[],ImuDataInfo &dataOut);

private:
      E_IMU_VENDOR_ID imuVendorId;
      bool isUseImu;
      int deviceCodeId;
      bool isInitialOkStatus;
      QSerialPort *serialPort_device;
      SerialPortConfig *serialPortConfig;
      int requestCount;
      int debugFlag;
      ImuDataInfo imuData;
      int maxTimeOutCount;
      modbus_t* modbusMaster;//modbus协议使用



};

#endif // IMUDEVICE_H
